<?php

declare(strict_types=1);

namespace SixShop\Wangdian\Services;

use SixShop\Wangdian\Response\ApiResponse;

/**
 * Goods service for products, specifications, etc.
 */
class GoodsService extends BaseService
{
    /**
     * Query goods information
     */
    public function query(array $params = []): ApiResponse
    {
        return $this->call('goods_query.php', $this->filterParams($params));
    }

    /**
     * Push goods information
     */
    public function push(array $goodsData): ApiResponse
    {
        $this->validateRequired($goodsData, ['goods_list']);

        return $this->call('goods_push.php', [
            'goods_list' => $this->encodeIfArray($goodsData['goods_list']),
        ]);
    }

    /**
     * Push goods specification
     */
    public function pushSpec(array $specData): ApiResponse
    {
        $this->validateRequired($specData, ['spec_list']);

        return $this->call('api_goods_spec_push.php', [
            'spec_list' => $this->encodeIfArray($specData['spec_list']),
        ]);
    }

    /**
     * Query suites (套装商品)
     */
    public function querySuites(array $params = []): ApiResponse
    {
        return $this->call('suites_query.php', $this->filterParams($params));
    }
}